package com.shisfish.library.Controller;

import java.util.HashMap;
import java.util.List;
import java.util.Map;

import javax.ws.rs.GET;
import javax.ws.rs.Path;
import javax.ws.rs.Produces;

import com.shisfish.library.Impl.PublisherImpl;
import com.shisfish.library.Model.Publisher;
import com.shisfish.library.Utils.Global.GlobalVariable;
import com.shisfish.library.Utils.Global.toJsonUtils;

@Path("publisher")
public class PublisherController extends GlobalVariable {

	private PublisherImpl publisherImpl = new PublisherImpl();
	
	/**
	 * @Author shisfish
	 * @Date 2016年1月7日 下午6:48:05
	 * @Descrition : 获得所有的出版社信息
	 * @return
	 */
	@GET
	@Path("selectAll")
	@Produces("application/json; charset=utf-8")
	public String selectAll() {
		Map<String, Object> globalMap = new HashMap<String, Object>();
		
		List<Publisher> publishers = publisherImpl.selectAll();
		
		if (publishers.size() > 0) {
			globalMap.put("list", publishers);
			globalMap.put(STATUS_CODE, SUCCESS);
		}
		else if (publishers.size() == 0) {
			globalMap.put(STATUS_CODE, SELECT_EMPTY);
		}
		else {
			globalMap.put(STATUS_CODE, SELECT_ERROR);
		}
		
		return toJsonUtils.map2Json(globalMap);
		
	}
	
}
